﻿
@{
    ViewBag.Title = "限制药品使用维护";
}

<div class="layui-fluid" id="LAY-limit-index">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <div class="layui-input-inline">
                        <select name="setFlag" id="setFlag">
                            <option value="">是否限制使用药品</option>
                            <option value="1">已限制使用药品</option>
                            <option value="0">未限制使用药品</option>
                            <option value="ALL">全部</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <div class="layui-input-inline">
                        <input class="layui-input" placeholder="药品编码" name="DrugCode" id="DrugCode">
                    </div>
                </div>
                <div class="layui-inline">
                    <div class="layui-input-inline">
                        <input class="layui-input" placeholder="药品名称" name="DrugName" id="DrugName">
                    </div>
                </div>
                <div class="layui-inline">
                    <div class="layui-input-inline">
                        <select name="ValidFlag" id="ValidFlag">
                            <option value="">状态</option>
                            <option value="1">有效</option>
                            <option value="0">无效</option>
                            <option value="ALL">全部</option>
                        </select>
                    </div>
                </div>

                <div class="layui-inline">
                    <button class="layui-btn layuiadmin-btn-list" lay-submit lay-filter="LAY-limit-search">
                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                    </button>
                </div>
            </div>
        </div>
        <div class="layui-card-body">
            <table id="LAY-limit-list" lay-filter="LAY-limit-list"></table>
            <script type="text/html" id="barBtn">
                <a class="layui-btn layui-btn-sm" lay-event="btndept">科室限制</a>
               
            </script>
        </div>
    </div>
</div>

<script type="text/javascript">
    layui.config({
        base: '/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table', 'admin'], function () {
        var table = layui.table
            , form = layui.form
            , $ = layui.$
            , admin = layui.admin;
        //数据绑定
        table.render({
            elem: '#LAY-limit-list'
            , url: '/LimitDrug/GetLimitDrugList' //模拟接口
            , toolbar: '#table-toolbar'
            , method: 'post'
            , height: 'full-130'
            , cols: [[
                { field: 'DrugCode', title: '药品编码', align: "center", width: 130 }
                , { field: 'DrugName', title: '药品名称', minWidth: 200 }
                , { field: 'Specs', title: '规格', width: 160 }
                , { field: 'UnitPrice', title: '单价', width: 100 }
                , { field: 'ValidFlag', title: '状态', templet: '<div>{{d.ValidFlag=="1"?"有效":"无效"}}</div>', width: 60 }
                , { field: 'right', title: '操作', width: 200, align: 'center', fixed: 'right', toolbar: '#barBtn' }
            ]]
            , page: true
            , limit: 10
            , limits: [10, 15, 20, 25, 30]
            , text: { none: '暂无数据' }
        });
        initTableBtn(table);

        //监听行工具事件
        table.on('tool(LAY-limit-list)', function (obj) {
            var data = obj.data;
            if (obj.event === 'btndept') {
                layer.open({
                    type: 2
                    , title: '科室限制维护'
                    , content: '/LimitDrug/EditDept?drugCode=' + data.DrugCode
                    , area: [($('#LAY-limit-index').width() - 60) + "px", ($('#LAY-limit-index').height() - 60) + "px"]
                });
            } 
        });
        //监听搜索
        form.on('submit(LAY-limit-search)', function (data) {
            var field = data.field;
            //执行重载
            table.reload('LAY-limit-list', {
                where: field,
                page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
        });

        var $ = layui.$;

        $('.layui-btn.layuiadmin-btn-list').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });
</script>
